package chat.commands;

import chat.clients.XmppClient;
import design.patterns.command.Command;
import org.jivesoftware.smack.XMPPException;

public class Login extends Command {
    private final XmppClient client;

    private String username;
    private String password;

    public Login(XmppClient client) {
        this.client = client;
    }

    @Override
    protected void protectedExecute() throws XMPPException {
        client.login(username, password);
    }

    public Login setUsername(String username) {
        this.username = username;

        return this;
    }

    public Login setPassword(char[] password) {
        return setPassword(new String(password));
    }

    private Login setPassword(String password) {
        this.password = password;
        return this;
    }
}
